<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<c:set var="queryList"
	value="${pageContext.request.contextPath}/position/list" />

	<div class="iframe-cot pull-right"  id="smIframe" style="background:#FFFFFF;">
		
		<div class="right-form">
			<form id="_query_form" action="" class="form-inline" onsubmit="return false;">
				<div class="tb_search">
                <div class="pull-left">
                	
					<div class="form-group">
						<label for="postName">岗位名：&nbsp;</label>
						 <input type="text" name="postName" value="${fn:escapeXml(postName) }"  />
					</div>
	
					<div class="form-group">
						<label for="unitId">&nbsp;机构：&nbsp;</label> 
						<input type="text" name="unitName" id="s_unitName" value="${fn:escapeXml(unitName) }" readOnly placeHolder="请选择" />
					   
					</div>
					
					<div class="form-group">
						<label for="status">状态：</label>
						<select  value="${status}" name="status" class="form-control-select" style="">
							<option value="" <c:if test="${ empty status }">selected='selected'</c:if>>请选择</option>
							<option value="1"
								<c:if test="${ '1' eq status }">selected='selected'</c:if>>启用</option>
							<option value="0"
								<c:if test="${ '0' eq status }">selected='selected'</c:if>>停用</option>
						</select>
					</div>
	
				</div>
				</div>
			</form>
		</div>
		
		<div class="line-e6e"></div>
		
		<div class="form-top">
             <div class="pull-left">
               <%--    <button class="btn btn-default" onclick="goAdd('${ctx}/position/goEdit','新增岗位')"><i class="fa fa-plus mr5"></i>新增</button>
                  <button class="btn btn-default" onclick="goUpdatePosition('${ctx}/position/goEdit?currentPage=${pageBean.currentPage}&pageSize=${pageBean.pageSize }','修改岗位信息')">
                  	<i class="fa fa-pencil mr5"></i>编辑</button>
             
             <button class="btn btn-default" onclick="enable()"><i class="fa fa-check-circle-o mr5"></i>启用</button>
             <button class="btn btn-default" onclick="ban()"><i class="fa fa-ban mr5"></i>停用</button>
              --%>
             </div>
             <div class="pull-right">
             <shiro:hasPermission name="common-service-position:query">
                  <a class="btn btn-orange" onclick="changePage('${queryList }','#_query_form','1','${pageBean.pageSize }',0)"><i class="fa fa-search mr5"></i>查询</a>
                  <a class="btn btn-blue" onclick="clearForm('#_query_form')"><i class="fa fa-trash-o mr5"></i>清空</a>
              </shiro:hasPermission>   
                 
                  </div>
            
             </div>
		
		<div class="table-scroll">

			<table id="_list_table" class="table-form table-bordered table-hover table-ellipsis table-fixed">
				<thead>
					<tr>
						<th width="5%"><input type="checkbox" name="checkboxall" id="fullCheck" onclick="listTableCheckAll(this)" /></th>
						<th width="5%">序号</th>
						<th>岗位名</th>
						<th>机构</th>
						<th>描述</th>
						<th width="50px">状态</th>
						<th width="100px">排序号</th>
					</tr>
				</thead>
				<tbody>
				 <c:if test="${ empty pageBean.data}">
                     <tr><td colspan="7">无符合条件记录</td></tr>
                    </c:if>
					<c:if test="${not empty pageBean.data}"></c:if>
					<c:forEach items="${pageBean.data}" var="position" varStatus="seq">
						<tr>
							<td><input type="checkbox" name="checkboxOne" id="oneCheck" value="${position.id }"/></td>
							<td>${seq.count+pageBean.first}</td>

							<td style="text-align:left" title="${position.postName}">${position.postName}</td>
							<td style="text-align:left" title="${position.unitName}">${position.unitName}</td>
							<td style="text-align:left" title="${position.description}">${position.description}</td>
							<td><c:out value="${'1' eq position.status?'启用':'停用'}" /></td>
							<td>${position.postOrder}</td>
							
						</tr>
					</c:forEach>

				</tbody>
			</table>
		</div>

		<div class="pages">
		 	<jsp:include page="../common/pager.jsp"></jsp:include>
		</div>

	</div>

	<!--main end-->
<div id="treediv" style='overflow:scroll;display:none; position:absolute;width:300px;height:200px;background-color:#eeffdd; border:1px solid #BEC0BF;padding:5px;font-size:12px;'>
	<a onclick="hidetreediv();" href="#" class="link-red mr5" style="cursor:pointer;color:red;text-align:right;"><i class="fa fa-close"></i>取消</a>
	<ul id="tree" class="ztree"></ul>
</div>
					    

<script type="text/javascript">

currentPageNo = parseInt('${pageBean.currentPage}');
currentPageSize = parseInt('${pageBean.pageSize }');
totalPageCount = parseInt('${pageBean.totalPage}');
queryUrl = '${ctx}/position/list';

$(document).ready(function() {
	$("#s_unitName").focus(function() {
		var divObj = $("#treediv");
		var txtObj = $("#s_unitName");
		showDiv(divObj,txtObj,unitsetting,"${ctx}/user/getUnit");
	});
});
//启用
function enable(){
	deleteById('请确认是否启用',1);
}
//停用
function ban(){
	deleteById('请确认是否停用',0);
}
//启用或停用
function deleteById(msg,status) {
	
	var ids = getListTableCheckboxValue() ;
	 if( ids == ''){
		 warnTip('请选择一条记录');
		 return;
	 }
	layer.confirm(msg, {
 	    btn: ['确定', '取消']
 	    ,yes: function(index){
 	    	$.post("${ctx}/position/deleteByIds",{'ids':ids,'status':status},function(result){
 	  		if(result.code=="success"){
 	  			 successTip();
 	  			//刷新列表
 	  			jumpPage();
 	  		}else{
 	  		errorTip();
 	  		}
 	  	},"json");
 	    }
 	});
	
	}

function goUpdatePosition(_url, _title) {
		
		var isCheckOne = isCheckOneWhenEdit();
		 if( !isCheckOne){
			 return;
		 }
		
		layer.open({
			type : 2,
			title : _title,
			maxmin : false,
			shadeClose : false, //点击遮罩关闭层
			area : [ '800px', '550px' ],
			content : _url + "&positionId=" + $("input[name='checkboxOne']:checked").val()
		});
}
	
	
</script>